package com.wyz.note.project.demo.service.impl;

import com.wyz.note.project.demo.pojo.UserInfo;
import com.wyz.note.project.demo.service.UserInfoExtendService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * @Description:
 * @Author: wei yz
 * @Date: 2022/6/16 16:45
 */
public class UserTaskService implements Runnable {
    private static final Logger log = LoggerFactory.getLogger(UserTaskService.class);


    private static int index = 0;

    private List<UserInfo> userInfoList;

    private UserInfoExtendService userInfoExtendService;

    public UserTaskService(List<UserInfo> userInfoList, UserInfoExtendService userInfoExtendService) {
        this.userInfoList = userInfoList;
        this.userInfoExtendService = userInfoExtendService;
    }

    @Override
    public void run() {
        index++;
        System.out.println("==> " + Thread.currentThread().getName() + " : " + index);
        log.info("保存数据[{}] ==> 大小：{}", index, userInfoList.size());
        userInfoExtendService.saveBatch(userInfoList);
    }

    public UserInfoExtendService getUserInfoExtendService() {
        return userInfoExtendService;
    }

    public void setUserInfoExtendService(UserInfoExtendService userInfoExtendService) {
        this.userInfoExtendService = userInfoExtendService;
    }

    public List<UserInfo> getUserInfoList() {
        return userInfoList;
    }

    public UserTaskService setUserInfoList(List<UserInfo> userInfoList) {
        this.userInfoList = userInfoList;
        return this;
    }
}
